package com.whw.fy.controller;

import com.whw.fy.entity.Message;
import com.whw.fy.entity.Staff;
import com.whw.fy.service.StaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "员工模块")
@RestController
@RequestMapping("/api/staff")
public class StaffController {
    @Resource
    private StaffService staffService;

    @ApiOperation(value = "新增员工")
    @PostMapping("/one")
    public Message insert(Staff staff) {
        return staffService.insertSelective(staff);
    }

    @ApiOperation(value = "根据id删除员工信息")
    @DeleteMapping("/id")
    public Message deleteById(Integer staffId) {
        return staffService.deleteByPrimaryKey(staffId);
    }

    @ApiOperation(value = "修改员工信息")
    @PostMapping("/update")
    public Message update(Staff staff) {
        return staffService.updateByPrimaryKeySelective(staff);
    }

    @ApiOperation(value = "根据员工id查看")
    @GetMapping("/id")
    public Message selectById(Integer staffId) {
        return staffService.selectByPrimaryKey(staffId);
    }

    @ApiOperation(value = "查看所有员工")
    @GetMapping("/all")
    public Message selectALL() {
        return staffService.selectAll();
    }

    @ApiOperation(value = "根据权限等级查询所有员工")
    @GetMapping("/selectAll/Jurisdiction")
    public Message selectAllByJurisdiction(int Jurisdiction){
        return staffService.selectAllByJurisdiction(Jurisdiction);
    }

    @ApiOperation(value = "根据权限等级查询所有员工姓名和工号")
    @GetMapping("/selectStaffnameAndStaffId/ByJurisdiction")
    public Message selectStaffnameAndStaffIdByJurisdiction(int Jurisdiction){
        return staffService.selectStaffnameAndStaffIdByJurisdiction(Jurisdiction);
    }
    @ApiOperation(value = "查询所有员工姓名和工号")
    @GetMapping("/selectStaffnameAndStaffId")
    public Message selectStaffnameAndStaffId(){
        return staffService.selectStaffnameAndStaffId();
    }


}
